﻿/*
 * 合同信息查看UI.szj 2009-11-22
 * 
 * 这里可以对合同进行操作。
 * 
 * */

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using EQT.Model;
using EQT.Dal;
using DevFuture.Common;
using Common.Logging;

public partial class PCCInfo : System.Web.UI.Page
{
    private static readonly ILog log = LogManager.GetCurrentClassLogger();
    private readonly DaProductCheckAbility dapca = WorkContext.AppCtx.GetObject("DaProductCheckAbility") as DaProductCheckAbility;
    private readonly DaProductCheckContract dapcc = WorkContext.AppCtx.GetObject("DaProductCheckContract") as DaProductCheckContract;
    private readonly DaContractTask dactask = WorkContext.AppCtx.GetObject("DaContractTask") as DaContractTask;
    private readonly DaTfiles datfile = WorkContext.AppCtx.GetObject("DaTfiles") as DaTfiles;
    private readonly DaReportAudit dara = DevFuture.Common.WorkContext.AppCtx.GetObject("DaReportAudit") as DaReportAudit;
    private readonly DaTuser dalUser = DevFuture.Common.WorkContext.AppCtx.GetObject("DaTuser") as DaTuser;
    private UserContext context;
    protected void Page_Load(object sender, EventArgs e)
    {
        context = Session["USER_CONTEXT"] as UserContext;
        if (!Page.IsPostBack)
        {
            //从查询字符串获取合同编号
            string report_id = Request.QueryString[0];

            #region 根据合同编号，显示合同
            if (!String.IsNullOrEmpty(report_id))
            {
                MoProductCheckContract mopcc=new MoProductCheckContract();
                mopcc.ReportId=report_id;
               //执行UI赋值
                if (dapcc.GetEntityEx(ref mopcc))
                {
                    
                    ViewState.Add("REPORT_ID", mopcc.ReportId);

                    LabelExperts.Text = Server.HtmlEncode(dara.GetReportAuditorNames(mopcc.ReportId, SiteConfig.REPORT_AUDIT_FLOW_1_EXPERT_AUDIT));

                    MoReportAudit audit= dara.GetAuditInfo(report_id, SiteConfig.REPORT_AUDIT_FLOW_1_EXPERT_AUDIT);
                    if (audit != null)
                    {
                        Label_Expert_Advice.Text = audit.AuditInfo;
                    }

                    #region 根据状态设置UI
                    Mo2UI(mopcc);
                    SetUIByPccState(mopcc);
                    #endregion

                    #region 设置UI风格
                    Utility.SetButtonStyle(SiteConfig.Common_Button_Css, Button_OK, Button_Send2Test, Button_Del_Pcc, Button_Send2Audit, ButtonConfirm);
                    #endregion

                    
                }
                else
                {
                    Utility.SiteError(String.Format("未给定有效的报告编号:{0}", report_id));
                }

            }        
            else
            {           
                Utility.SiteError("报告编号是必须的参数.");
            }
            #endregion

            BindDDLRejectTO();
        }
      

    }

    #region Mo2UI
    /// <summary>
    /// 将实体的值赋给UI
    /// </summary>
    /// <param name="mopcc"></param>
    private void Mo2UI(MoProductCheckContract mopcc)
    {        
        //在这里呈现合同编号和状态
        Label_Report_ID.Text = mopcc.ReportId;

        #region 甲方信息
        Label_Corp_Name.Text = mopcc.CorpName;
        Label_Charge.Text = mopcc.Charge.ToString("C");
        Label_Report_Status.Text = ContractStatusCollection.GetContractStatusText(mopcc.ReportStatus);//使用工具类获取状态
        Label_Client_ID.Text = String.IsNullOrEmpty(mopcc.ClientId) ? "N/A" : mopcc.ClientId;
        labCheckTime.Text = mopcc.Class1;
        Label_Corp_Addr.Text = Server.HtmlEncode(
            String.Format("地址:{0} 邮编:{1} ", mopcc.Addr, mopcc.Postcode)
            );
        Label_Tel_Email.Text = Server.HtmlEncode(
            String.Format("委托人/联系人:{0}/{1}  电话/传真:{2}/{3}  Email:{4}", mopcc.Consigner, mopcc.Linkman,
            mopcc.Tel, mopcc.Fax, mopcc.Email)
        );

        #endregion

        #region 参数文件
        if (String.IsNullOrEmpty(mopcc.FidParameter))
        {
            //TODO:检查权限
            Button_Del_Par_File.Visible = false;
            btnUploadParFile.Visible = true;
            btnUploadParFile.Attributes.Add("OnClick", "InvokePopUploadParFile('" + mopcc.ReportId + "')");
        }
        else
        {
            Utility.CreateTFileHyperLink(HyperLink_Par_File, mopcc.FidParameter, "单击此处下载参数文件");
            //允许删除
            //TODO:检查权限
            Button_Del_Par_File.Visible = true;
            btnUploadParFile.Visible = false;
        }

       
        #endregion

        #region 原始记录及自动生成的报告文件
        if (!String.IsNullOrEmpty(mopcc.FidDdlDoc))
        {
            Utility.CreateTFileHyperLink(HyperLink_DOC_DDL, mopcc.FidDdlDoc, "单击此处下载原始记录文件.");
        }
        else
        {
            HyperLink_DOC_DDL.Text = "试验记录还未上传";
            HyperLink_DOC_DDL.NavigateUrl = "#";
            HyperLink_DOC_DDL.ToolTip = "原始记录未上传，或者后台处理程序还未处理。请查看任务状态确定情况。";
        }
        if (!String.IsNullOrEmpty(mopcc.FidDrlDoc))
        {
            Utility.CreateTFileHyperLink(HyperLink_DOC_DRL, mopcc.FidDrlDoc, "单击此处下载原始记录文件.");
        }
        else
        {
            HyperLink_DOC_DRL.Text = "试验记录还未上传";
            HyperLink_DOC_DRL.NavigateUrl = "#";
            HyperLink_DOC_DRL.ToolTip = "原始记录未上传，或者后台处理程序还未处理。请查看任务状态确定情况。";
        }

        if (!String.IsNullOrEmpty(mopcc.FidReportDoc))
        {
            Utility.CreateTFileHyperLink(HyperLink_Report_File, mopcc.FidReportDoc, "单击此处下载报告文件.");
        }

        if (!String.IsNullOrEmpty(mopcc.MannulReportDoc))
        {
            Utility.CreateTFileHyperLink(HyperLink_Report_Mannul, mopcc.MannulReportDoc, "单击此处下载最终报告文件.");
        }

       

        #endregion      

        #region 获取产品检测能力信息
        MoProductCheckAbility mopca = new MoProductCheckAbility();
        mopca.PcaId = mopcc.PcaId;
        if (dapca.GetEntityEx(ref mopca))
        {
            //任务的原始信息 
            #region 任务信息
            Label_Task_DDL.Text = EqtAsmKeys.Task_DDL_Name;
            CheckBox_DDL_Req.Checked = !String.IsNullOrEmpty(mopca.TltXlsDdl);
            if (CheckBox_DDL_Req.Checked)
            {
                Utility.CreateTFileHyperLink(HyperLink_Tlt_Xls_DDL, mopca.TltXlsDdl, null);
            }
            Label_Task_DRL.Text = EqtAsmKeys.Task_DRL_Name;
            CheckBox_DRL_Req.Checked = !String.IsNullOrEmpty(mopca.TltXlsDrl);
            if (CheckBox_DRL_Req.Checked)
            {
                Utility.CreateTFileHyperLink(HyperLink_Tlt_Xls_DRL, mopca.TltXlsDrl, null);
            }

            #endregion
            //标题
            Label_Contract_Title.Text = String.Format("{0}●{1}({2})检验合同",
                    mopcc.CorpName, mopca.Pname, mopca.Pmodel);
            Label_PName.Text = mopca.Pname;
            Label_PModel.Text = mopca.Pmodel;
            Label_PType.Text = mopca.Ptype;
            //赋值到UI完毕
            //2010-3-5 szj 添加参数模板下载link
            Utility.CreateTFileHyperLink(HyperLinkParaTemplate, mopca.TltXlsPtype, "单击此处下载.","下载参数登记表模板");
        }
        else
        {
            Utility.SiteError(String.Format("检验能力信息无效:{0}", mopcc.PcaId));
        }
        #endregion

        RepFile.DataSource = dapcc.GetPccAttach(mopcc.ReportId);
        RepFile.DataBind();

    }
    #endregion

    /// <summary>
    /// 为退回绑定用户组 2010-3-4 变更
    /// </summary>
    private void BindDDLRejectTO()
    {
        
        DDL_RejectTO.DataTextField = "RoleName";
        DDL_RejectTO.DataValueField = "RoleId";
        DaTrole darole = WorkContext.AppCtx.GetObject("DaTrole") as DaTrole;
        DDL_RejectTO.DataSource = darole.GetEntities(String.Format(" WHERE ROLE_ID='{0}' OR ROLE_ID='{1}' OR ROLE_ID='{2}'",
            MoTrole.Constants.ROLE_ReportGroup,MoTrole.Constants.ROLE_TesterGroup_DDL,MoTrole.Constants.ROLE_TesterGroup_QDL
            ) );
        DDL_RejectTO.DataBind();
    }

    protected void Button_OK_Click(object sender, EventArgs e)
    {
        //返回到合同查询UI
        Response.Redirect("PCCQuery.aspx",true);
    }

    /// <summary>
    /// 送检
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button_Send2Test_Click(object sender, EventArgs e)
    {
        //送检
        string report_id = ViewState["REPORT_ID"] as string;
        MoProductCheckContract mopcc = new MoProductCheckContract();
        mopcc.ReportId = report_id;
        if (dapcc.GetEntityEx(ref mopcc)) //得到已创建的合同
        {
            if (String.IsNullOrEmpty(mopcc.FidParameter))
            {
                AjaxScriptManager.Page.ClientScript.RegisterStartupScript(this.GetType(), "ReturnScript", "alert('未上传样品参数，不能送检！');", true);
                return;
            }

            if (dapcc.SendPcc2Test(mopcc, dapca, dactask) > 0)
            {
                //送检成功，刷新页面赋值
                mopcc.ReportStatus = (int)ContractStatus.WaitTest;
                Mo2UI(mopcc);
                Button_Send2Test.Enabled = false;
            }
            else
            {
                Utility.SiteError(String.Format("合同{0}送检失败，请联系系统管理员.", mopcc));
            }
           
        }      

    }

    /// <summary>
    /// 删除合同
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button_Del_Pcc_Click(object sender, EventArgs e)
    {
        string report_id = ViewState["REPORT_ID"] as string;
        MoProductCheckContract mopcc = new MoProductCheckContract();
        mopcc.ReportId = report_id;
        if (dapcc.GetEntityEx(ref mopcc) && mopcc.ReportStatus <= (int)ContractStatus.Signed) //得到已创建的合同
        {
            if (dapcc.DeletePcc(mopcc, dactask) > 0)
            {
                UserContext uc = Session["USER_CONTEXT"] as UserContext;
                DaActLog.LogOperation(uc.UserID, "NORMAL_ACT", String.Format("删除合同{0}", mopcc));
                //返回到合同查询UI
                Response.Redirect("PCCQuery.aspx");
            }
            else
            {
                Utility.SiteError(String.Format("合同{0}送检失败，请联系系统管理员.", mopcc));
            }

        }
        else
        {
            Utility.SiteError(String.Format("合同{0}不存在，或者其状态不允许删除.", mopcc));
        }

    }

    /// <summary>
    /// 上传参数文件,一个报告，可以有多个参数文件，但应该只有一个Excel格式的可解析的参数文件.
    /// 目前要求参数文件中的标签是特殊格式的，才可以在多个报告中引用。2009-6-1
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUploadParFile_Click(object sender, EventArgs e)
    {
        //刷新参数
        string report_id = ViewState["REPORT_ID"] as string;
        MoProductCheckContract mopcc = new MoProductCheckContract();
        mopcc.ReportId = report_id;
        if (dapcc.GetEntityEx(ref mopcc) && (!String.IsNullOrEmpty(mopcc.FidParameter)))
        {
            Utility.CreateTFileHyperLink(HyperLink_Par_File, mopcc.FidParameter, "");
            Button_Del_Par_File.Visible = true;
            btnUploadParFile.Visible = false;
        }
        else
        {
            Button_Del_Par_File.Visible = false;
            btnUploadParFile.Visible = true;
        }
        
    }
    protected void BtnUploadParAttHidden_Click(object sender, EventArgs e)
    {
        string report_id = ViewState["REPORT_ID"] as string;
        RepFile.DataSource = dapcc.GetPccAttach(report_id);
        RepFile.DataBind();
    }

    /// <summary>
    /// 上传完参数文件后会被回调
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUploadParAtt_Click(object sender, EventArgs e)
    {
        string report_id = ViewState["REPORT_ID"] as string;
        //TODO:
    }

    protected void Button_Del_Par_File_Click(object sender, EventArgs e)
    {
        string report_id = ViewState["REPORT_ID"] as string;

        dapcc.DelProductParameterFile(report_id, datfile);

        Button_Del_Par_File.Visible = false;
        btnUploadParFile.Visible = true;

        HyperLink_Par_File.Text = "无参数文件";
        HyperLink_Par_File.NavigateUrl = "#";
        HyperLink_Par_File.ToolTip = "请上传参数文件";
    }

    /// <summary>
    /// 上传最终报告文件之后
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button_UploadReportMannul_Click(object sender, EventArgs e)
    {
        //刷新最终报告
        string report_id = ViewState["REPORT_ID"] as string;
        MoProductCheckContract mopcc = new MoProductCheckContract();
        mopcc.ReportId = report_id;
        if (dapcc.GetEntityEx(ref mopcc) && (!String.IsNullOrEmpty(mopcc.MannulReportDoc)))
        {
            HyperLink_Report_Mannul.Visible = true;
            Utility.CreateTFileHyperLink(HyperLink_Report_Mannul, mopcc.MannulReportDoc, "");
            Button_Del_Report_Mannul.Visible = true;
            Button_UploadReportMannul.Visible = false;
        }
        else
        {
            HyperLink_Report_Mannul.Visible = false;
            Button_Del_Report_Mannul.Visible = false;
            Button_UploadReportMannul.Visible = true;
        }
    }

    protected void Button_Del_Report_Mannul_Click(object sender, EventArgs e)
    {
        UserContext uc = Session["USER_CONTEXT"] as UserContext;
       
        string report_id = ViewState["REPORT_ID"] as string;
        dapcc.DelMannulReportFile(report_id, datfile);

        log.WarnFormat("{0}删除了{1}的手工报告文件{2}.",uc,report_id,HyperLink_Report_Mannul.NavigateUrl);

        HyperLink_Report_Mannul.Visible = false;
        Button_Del_Report_Mannul.Visible = false;
        Button_UploadReportMannul.Visible = true;
    }

    #region BtnSelectAuditor_Click 选择后呈现审批人
    /// <summary>
    /// 绑定审批人
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void BtnSelectAuditor_Click(object sender, EventArgs e)
    {
        LabelExperts.Text = Server.HtmlEncode(dara.GetReportAuditorNames(ViewState["REPORT_ID"].ToString(),
            SiteConfig.REPORT_AUDIT_FLOW_1_EXPERT_AUDIT));     

    }
    #endregion

    /// <summary>
    /// 送审
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button_Send2Audit_Click(object sender, EventArgs e)
    {
        MoProductCheckContract pcc = new MoProductCheckContract();
        pcc.ReportId = ViewState["REPORT_ID"].ToString();
        dapcc.ReplaceContractStatus(pcc.ReportId, (int)ContractStatus.WaitConfirm1);
        dapcc.GetEntityEx(ref pcc);        
        SetUIByPccState(pcc);
    }


    #region 权限检查
    /// <summary>
    /// 根据权限设置UI，仅在UI加载是执行一次.默认的，权限的ID都使用 对象名.资源名 。
    /// 如果资源必须与UI一同显示，则权限就是UI的名字。
    /// 2010-3-5:权限检查的思路是：先假设人员具有所有权限，再根据他实际具有的权限，一一进行检查
    /// </summary>
    private void SetUIByRights()
    {
        //编辑合同
        if (dalUser.CheckUserPrivilege(context.UserID,
            "PCCInfo.Edit"))
        {
            Button_Del_Par_File.Visible = true;
            btnUploadParFile.Visible = true;
            btnUploadParAtt.Visible = true;
        }
        else
        {
            Button_Del_Par_File.Visible = false;
            btnUploadParFile.Visible = false;
            btnUploadParAtt.Visible = false;
        }

        //删除合同
        if (Button_Del_Pcc.Visible) Button_Del_Pcc.Visible = dalUser.CheckUserPrivilege(context.UserID, "PCCInfo.Del_Pcc");
        //送检 
        if (Button_Send2Test.Visible) Button_Send2Test.Visible = dalUser.CheckUserPrivilege(context.UserID, "PCCInfo.Send2Test");

        //以下是报告组的权限
        //送审
        if (Button_Send2Audit.Visible) Button_Send2Audit.Visible = dalUser.CheckUserPrivilege(context.UserID, "PCCInfo.Send2Audit");
        //能送审的，则可以选择专家
        if (BtnSelectExperts.Visible) BtnSelectExperts.Visible = dalUser.CheckUserPrivilege(context.UserID, "PCCInfo.Send2Audit");
        //删除手工上传的报告
        if (Button_Del_Report_Mannul.Visible) Button_Del_Report_Mannul.Visible = dalUser.CheckUserPrivilege(context.UserID, "PCCInfo.Del_Rpt");
        //上传手工报告
        if (Button_UploadReportMannul.Visible) Button_UploadReportMannul.Visible = dalUser.CheckUserPrivilege(context.UserID, "PCCInfo.UploadRpt");

        //批准报告
        if (ButtonConfirm.Visible) ButtonConfirm.Visible = dalUser.CheckUserPrivilege(context.UserID, "PCCInfo.ConfirmRpt");
          
    }


    #endregion

    #region 根据合同状态设置UI
    /// <summary>
    /// 根据合同状态设置UI 
    /// </summary>
    private void SetUIByPccState(MoProductCheckContract mo)
    {
        #region 首先全部重置为不可见
        //删除合同
        if (Button_Del_Pcc.Visible) Button_Del_Pcc.Visible = false;
        //送检 
        if (Button_Send2Test.Visible) Button_Send2Test.Visible = false;
        //送审
        if (Button_Send2Audit.Visible) Button_Send2Audit.Visible = false;
        if (BtnSelectExperts.Visible) BtnSelectExperts.Visible = false;
        if (Button_Del_Report_Mannul.Visible) Button_Del_Report_Mannul.Visible = false;
        if (Button_UploadReportMannul.Visible) Button_UploadReportMannul.Visible = false;

        //批准报告
        if (ButtonConfirm.Visible) ButtonConfirm.Visible = false;
        
        #endregion
        switch (mo.ReportStatus)
        {
            case (int)ContractStatus.Signed://已签订
                {
                    //送检 
                    if (!Button_Send2Test.Visible) Button_Send2Test.Visible = true;
                    break;
                }                 
            case (int)ContractStatus.WaitReport://检验完成待整理
                {
                    if (!Button_Send2Audit.Visible) Button_Send2Audit.Visible = true;
                    if (!BtnSelectExperts.Visible) BtnSelectExperts.Visible = true;
                    if (!Button_Del_Report_Mannul.Visible) Button_Del_Report_Mannul.Visible = true;
                    if (!Button_UploadReportMannul.Visible) Button_UploadReportMannul.Visible = true;
                    break;
                }          
            case (int)ContractStatus.WaitConfirm1://报告整理完成/待审核
                {
                    //审核按钮
                    if (dara.IsExistAuditor(context.UserID, mo.ReportId, SiteConfig.REPORT_AUDIT_FLOW_1_EXPERT_AUDIT))
                    {
                        if (!ButtonConfirm.Visible) ButtonConfirm.Visible = true;
                    }                    
                    break;
                }
        }

        SetUIByRights(); //根据权限设置按钮状态

        #region 最终报告文件上传
        if (String.IsNullOrEmpty(mo.MannulReportDoc))
        {
            if (Button_UploadReportMannul.Visible)//权限和状态都要求其可见
                Button_UploadReportMannul.Attributes.Add("OnClick", "InvokePopUploadFinalReport('" + mo.ReportId + "')");
        }
        else
        {
            if (Button_UploadReportMannul.Visible) Button_UploadReportMannul.Visible = false;             
        }
        #endregion

        
        #region 设置弹出脚本
        if (BtnSelectExperts.Visible)
        {
            BtnSelectExperts.Attributes.Add("OnClick",
                "InvokePopSelectAuditor('" + ViewState["REPORT_ID"].ToString() + "','" + SiteConfig.REPORT_AUDIT_FLOW_1_EXPERT_AUDIT + "')");
        }
        if (btnUploadParAtt.Visible)
        {
            btnUploadParAtt.Attributes.Add("OnClick", "InvokePopUploadParAttach('" + ViewState["REPORT_ID"].ToString() + "')");
        }
        #endregion

        
    }
    #endregion

   
   

    /// <summary>
    /// 确认是否同意此报告
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ButtonConfirm_Click(object sender, EventArgs e)
    {        
        this.programmaticModalPopup.Show();
        
    }



    /// <summary>
    /// 专家组审批后，报告就算完成。
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void OkButton_Click(object sender, EventArgs e)
    {        
        MoProductCheckContract pcc = new MoProductCheckContract();
        pcc.ReportId = ViewState["REPORT_ID"].ToString();
        if (RadioButton_Confirm.Checked)
        {
            dapcc.ReplaceContractStatus(ViewState["REPORT_ID"].ToString(),
                (int)ContractStatus.Done);
        }
        else //被退回
        {
            //2010-3-4 审核后未通过的要有选择的退回给以下三个角色:A:报告组;B:大容量检验组;C:大电流检验组.

            //更新合同到特定状态。
            //1、如果退回到报告组，则更新报告状态为[检验完成]，意味着重新作报告
            //2、若退回到大容量检验组，则更新报告状态为[试验中]，并更新此报告对应的大容量检验组的任务为[已创建，待试验]
            //3、若退回到大电流检验组，则更新报告状态为[试验中]，并更新此报告对应的大电流检验组的任务为[已创建，待试验]
            if (DDL_RejectTO.SelectedValue == MoTrole.Constants.ROLE_ReportGroup)
            {
                dapcc.ReplaceContractStatus(ViewState["REPORT_ID"].ToString(),
                   (int)ContractStatus.WaitReport);
            }
            else
            {
                //更新到
                dapcc.RejectTask(
                    ViewState["REPORT_ID"].ToString(), 
                    DDL_RejectTO.SelectedValue,
                    TextBox_Confirm_Advice.Text,
                    Session["USER_CONTEXT"] as UserContext,
                    WorkContext.AppCtx.GetObject("DaContractTask") as DaContractTask, 
                    WorkContext.AppCtx.GetObject("DaNotice") as DaNotice);
            }
        }

        dara.UpdateReportAuditRem(pcc.ReportId, SiteConfig.REPORT_AUDIT_FLOW_1_EXPERT_AUDIT, TextBox_Confirm_Advice.Text,
                context.UserID);
        dapcc.GetEntityEx(ref pcc);
        Mo2UI(pcc);
        SetUIByPccState(pcc);
        Label_Expert_Advice.Text = TextBox_Confirm_Advice.Text;
        this.programmaticModalPopup.Hide();
    }

    protected void RepFile_OnItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            if (e.CommandName == "del")
            {
                datfile.DeleteOneAttachFile(e.CommandArgument.ToString());
                BtnUploadParAttHidden_Click(null, null);
            }
        }
    }

    protected void RepFile_OnItemDataBound(object source, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            e.Item.FindControl("btnDeleteAttachment").Visible = dalUser.CheckUserPrivilege(context.UserID,
            "PCCInfo.Edit");         
        }
    }



}
